<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<style>
    .default {
        width: 100px;
        height: 100px;
        background-color: #000;
    }

    .style1 {
        background-color: aqua;
    }

    .style2 {
        background-color: red;
    }

    .style3 {
        background-color: yellow;
    }

    .style4 {
        background-color: blue;
    }
</style>

<body>
<div id="box">
    <div class="default" :class="className"></div>
    <button @click="changeStyle">点我修改样式</button>
</div>
</body>
<script src="script/vue.js"></script>
<script>
    let vue = new Vue({
        el: '#box',
        data: {
            className: []
        },
        methods: {
            changeStyle() {
                let styleArray = ['style1', 'style2', 'style3', 'style4'];
                let index = Math.floor(Math.random() * 4);
                console.log('随机样式为：', index);
                this.className = [];
                this.className.push(styleArray[index]);
            }
        }
    })
</script>
</html>